package com.example.demo.controller;

import com.example.demo.model.Area;
import com.example.demo.model.Pages;
import com.example.demo.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping(value = "area")
public class AreaController {

    @Autowired
    private  ElasticsearchTemplate elasticSearchTemplate;
    @Autowired
    private AreaService areaService;

    @GetMapping(value="index")
    public String  index() {
        return "area/index";
    }
    @PostMapping(value="list")
    public @ResponseBody
    Pages<Area> list(Integer pageNumber, Integer pageSize, String searchContent) {
        return areaService.searchAreaPage(pageNumber, pageSize, searchContent);
    }

    @GetMapping("/add")
    public void saveLog(){
        Area a = new Area(2l,2l,"adf34","dfadf34","mergename123", (short) 1,"pingyin","code","zipcode","123","123.1,34.5");
        areaService.saveArea(a);
    }
}
